py31compat.py 562 B

1234567891011121314151617181920212223
  1. import os
  2. import errno
  3. import sys
  4. from pip._vendor import six
  5. def _makedirs_31(path, exist_ok=False):
  6. try:
  7. os.makedirs(path)
  8. except OSError as exc:
  9. if not exist_ok or exc.errno != errno.EEXIST:
  10. raise
  11. # rely on compatibility behavior until mode considerations
  12. # and exists_ok considerations are disentangled.
  13. # See https://github.com/pypa/setuptools/pull/1083#issuecomment-315168663
  14. needs_makedirs = (
  15. six.PY2 or
  16. (3, 4) <= sys.version_info < (3, 4, 1)
  17. )
  18. makedirs = _makedirs_31 if needs_makedirs else os.makedirs